package cn.kongwg.utils;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.dbutils.DbUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
 * @author kongwg
 * @create 2021-01-25 18:28
 */
public class WebUtils {

    public static <T> T copyParamToBean(Map map, T t) {

        try {
            BeanUtils.populate(t, map);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return t;
    }


    public static int parseToInt(String str, int defaultVal) {
        if (str != null) {
            int i = 0;
            try {
                i = Integer.parseInt(str);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            return i;
        }
        return defaultVal;
    }
}
